﻿namespace WinForms
{
    using System;
    using System.ComponentModel;
    using System.Windows.Forms;

    public class ComboBoxNew : ComboBox
    {
        private IContainer components = null;

        public ComboBoxNew()
        {
            this.InitializeComponent();
            base.DropDownStyle = ComboBoxStyle.DropDownList;
            base.DisplayMember = "Name";
            base.ValueMember = "Value";
        }

        public void AddItem(string name, string value)
        {
            base.Items.Add(new ComboxItem(name, value));
        }

        protected override void Dispose(bool disposing)
        {
            if (disposing && (this.components != null))
            {
                this.components.Dispose();
            }
            base.Dispose(disposing);
        }

        private void InitializeComponent()
        {
            this.components = new Container();
        }

        protected override void OnPaint(PaintEventArgs pe)
        {
            base.OnPaint(pe);
        }

        public string SelectValueNew
        {
            get
            {
                string str = "";
                if (base.SelectedItem != null)
                {
                    str = ((ComboxItem) base.SelectedItem).Value.ToString();
                }
                return str;
            }
            set
            {
                int num = 0;
                string str = value;
                if (value != "")
                {
                    for (int i = 0; i < base.Items.Count; i++)
                    {
                        ComboxItem item = (ComboxItem) base.Items[i];
                        if (item.Value.ToString() == str)
                        {
                            num = i;
                        }
                    }
                    if (str != "")
                    {
                        this.SelectedIndex = num;
                    }
                }
            }
        }
    }
}

